<?php
/**
 * Created by PhpStorm.
 * User: sks
 * Date: 2015/12/15
 * Time: 13:49
 */

/**
 * Class Involved_AdminModel
 */

class Involved_AdminModel extends BaseModel{

    protected $table = 'admin_user';


    /**
     * 管理员列表
     * @return mixed
     */
    public function ManageAdmin()
    {
        return  DB::table($this->table) ->orderby('add_time','desc')->get();
    }

    public function GetAdminInfo($user_id)
    {
        return DB::table($this->table)->where('user_id',$user_id)->first();
    }

    public function getLoginAdminInfo($name,$pwd)
    {
         return DB::table($this->table)
             ->select('user_id','user_nick','name','telephone','avatar','role_id')
             ->where(['telephone'=>$name,'password'=>$pwd,'status'=>1])
             ->first();

    }

    public function AdminMessage($uid){
        return DB::table($this->table)
            ->select('user_nick')
            ->where(['user_id'=>$uid])
            ->first();
    }

    public function AdminRole($roid,$uid){
        return DB::table($this->table)
            ->select('user_nick','user_id')
            ->where(['role_id'=>$roid])
            ->where('user_id', '!=' ,$uid)
            ->get();
    }
    /**
    *查询添加管理员手机号是不是存在
     **/
    public function PhoneAdminInfo($phone){
        return DB::table($this->table)
            ->where(['telephone'=>$phone])
            ->first();
    }





}